#include <iostream>
#include <list>
#include <algorithm>
// c++ primer plus 1209
template <class T>
class Func {
    public:
    Func(T t):threshold_(t){};
    bool operator() (T at) {
        return at > threshold_;
    }
    private:
    T threshold_;
};
void outint(int i){
    using namespace std;
    cout << i << endl;
}

int functor_main()
{
    std::list<int> aList = {10, 20, 30, 50, 100, 200, 324, 421};
    std::list<int> bList = {10, 20, 30, 50, 100, 200, 324, 421};
    Func<int> f100(100);
    aList.remove_if(f100);
    std::cout << "aList最后结果是:" << std::endl;
    std::for_each(aList.begin(), aList.end(), outint);

    bList.remove_if(Func<int>(200)); //这里创建的是一个匿名对象
    std::cout << "bList最后结果是:" << std::endl;
    std::for_each(bList.begin(), bList.end(), outint);
    return 0;
}
